package com.springboot.demo.seria_deseria.core;

import java.time.ZoneId;
import java.util.TimeZone;

public enum CountryEnum {
    China(45,"CN","CHN", "China", TimeZone.getTimeZone("GMT+8:00").toZoneId(), "RMB", 0, "中国"),
    Mexico(142, "MX", "MEX", "Mexico", TimeZone.getTimeZone("GMT-6:00").toZoneId(),"MXN",0, "墨西哥"),
    SouthAfrica(202,"ZA","ZAF", "SouthAfrica", TimeZone.getTimeZone("GMT+2:00").toZoneId(),"ZAR",1, "南非"),
    UnitedState(231,"US","USA", "UnitedState", TimeZone.getTimeZone("GMT-5:00").toZoneId(),"USD",0,"美国"),
    Undefined(999, "MX", "MEX","Undefined", TimeZone.getTimeZone("GMT-6:00").toZoneId(),"MXN",0,"未定义");

    private final int countryId;    //国家id
    private final String code2;     //国家二字码
    private final String code3;     //国家三字码
    private final String countryName;
    private final ZoneId zoneId;   //zoneId
    private final String currency;  //货币
    private final int blayer; //分销B端用户等级
    private final String desc;      //说明

    public static String Country_ID="country-id";

    public int getCountryId() {
        return countryId;
    }

    public String getCode2() {
        return code2;
    }

    public String getCode3() {
        return code3;
    }

    public String getCountryName() {
        return countryName;
    }

    public ZoneId getZoneId() {
        return zoneId;
    }

    public String getCurrency() {
        return currency;
    }

    public int getBLayer() {
        return blayer;
    }

    public String getDesc() {
        return desc;
    }


    CountryEnum(int countryId, String code2, String code3, String countryName, ZoneId zoneId, String currency, int blayer, String desc) {
        this.countryId = countryId;
        this.code2 = code2;
        this.code3 = code3;
        this.countryName = countryName;
        this.zoneId=zoneId;
        this.currency=currency;
        this.blayer = blayer;
        this.desc = desc;
    }

    public static CountryEnum getItem(int countryId) {
        for (CountryEnum countryEnum : CountryEnum.values()) {
            if (countryEnum.getCountryId()==countryId) {
                return countryEnum;
            }
        }

        return CountryEnum.Mexico;
    }

}
